import { request } from 'umi';

// 获取设备列表
export async function getDeviceList(params) {
  return request('/api/v1/device', {
    method: 'GET',
    params,
  });
}

// 获取场地列表
export async function getVenues() {
  return request('/api/v1/venue', {
    method: 'GET',
  });
}

// 获取门店列表
export async function getStores() {
  return request('/api/v1/store', {
    method: 'GET',
  });
}

// 获取设备详情
export async function getDeviceDetail(id) {
  return request(`/api/v1/device/${id}`, {
    method: 'GET',
  });
}

// 创建设备
export async function createDevice(data) {
  return request('/api/v1/device', {
    method: 'POST',
    data,
  });
}

// 更新设备
export async function updateDevice(data) {
  return request(`/api/v1/device/${data.id}`, {
    method: 'PUT',
    data,
  });
}

// 删除设备
export async function deleteDevice(id) {
  return request(`/api/v1/device/${id}`, {
    method: 'DELETE',
  });
}

// 更新设备状态
export async function updateDeviceStatus(id, status) {
  return request(`/api/v1/device/${id}/status`, {
    method: 'PUT',
    data: { status },
  });
}

// 获取设备类型列表
export function getDeviceTypeOptions() {
  return [
    { label: '门禁', value: 1 },
    { label: '其他', value: 2 },
  ];
}

// 获取设备状态列表
export function getDeviceStatusOptions() {
  return [
    { label: '离线', value: 0 },
    { label: '正常', value: 1 },
    { label: '故障', value: 2 },
  ];
}
